<?php
/*
 * Creative Bulletin Board Generation 3
 * Version 1.0 Beta 1
 +------------------------------------
 * User Application Controller: Permission Mask
 * Started: September 21, 2009 2:25 PM (Week 1, Day 3)
 * Script version: 1.0
 */
class permissionmask{
	public function __construct($identifier){
		global $db;
		$this->pid = intval($identifier);
		$query = $db->select("permission_masks", "*", "1", " WHERE `id` = {$this->pid}");
		if($query){
			if($db->num_rows($query) == 0){
				$this->status = false;
			}
			else{
				$this->mask = $db->fetch_array($query);
				$this->status = true;
			}
		}
		else{
			$this->status = false;
		}
		//---------------------------------------
		// We shall not need any permission individual
		// initialization. Thanks though.
	}
	
	public function getStatus(){
		return $this->status;
	}
	
	public function getName(){
		return $this->mask['name'];
	}
	
	public function getID(){
		return $this->mask['id'];
	}
	
	public function getDesc(){
		return $this->mask['description'];
	}
	
	public function delete(){
		global $db;
		// TODO: Check if groups assigned this pmask. Or? I dunno.
		$query = $db->query("DELETE FROM `".DB_PREFIX."permission_masks` WHERE `id` = {$this->pid} LIMIT 1");
		return $query;
	}
}
